//****************************************************************************
//
// LED blink example
//
//****************************************************************************

#configure board        hu_arm_v4
#configure clcd_lines   2
#configure memory       rom
#configure baudrate     38400

#include "pRTOS.h"
#include "armboard.h"

int main( void ){
   RTOS::run();
   return 0;
}

// end of standard part

void led_set( int n, int v ){
   static int leds = 0;   
   if( v ){ leds |= 1 << n; } else { leds &=~ 1 << n; }
   armboard::LEDs::write( leds );
}

class blinker : public RTOS::task {
public:
   blinker( int LED, int period ): 
      LED( LED ), period( period ){}
private:
   int LED, period;
   void main( void ){
      for(;;){
         led_set( LED, 1 );
         sleep( period / 2 );
         led_set( LED, 0 );
         sleep( period / 2 );
      }
   }
};

blinker led0( 0, 1000 MS );
blinker led1( 1,  300 MS );


